<?php if ( ! defined('WDK_PATH')) exit('No direct script access allowed');?>
<!--{**************************************************************************}-->
<style>
.validated	{border:1px solid #117808;background-color: #BAFFA5;}
</style>
<!--{**************************************************************************}-->
<h1 class="title">회원 가입</h1>
<form name="join_form" action="" method="POST">
<input type="hidden" name="login_id_validation" value=""/>
<input type="hidden" name="email_validation" value=""/>
<table class="form">
	<colgroup>
		<col width="20%"/>
		<col width="30%"/>
		<col width="20%"/>
		<col width="30%"/>
	</colgroup>
	<tbody>
		<tr>
			<th>아이디 <em>*</em></th>
			<td>
				<input type="text" name="user_login_id" class="input"/>
				<a id="btn_id_check" class="btn" href="javascript:;">중복체크</a>
			</td>
			<th>Email <em>*</em></th>
			<td>
				<input type="text" name="user_email" class="input"/>
				<a id="btn_email_check" class="btn" href="javascript:;">중복체크</a>
			</td>
		</tr>
		<tr>
			<th>비밀번호 <em>*</em></th>
			<td><input type="password" name="user_login_passwd" class="input"/></td>
			<th>비밀번호확인 <em>*</em></th>
			<td><input type="password" name="confirm_passwd" class="input"/></td>
		</tr>
		<tr>
			<th>이름 <em>*</em></th>
			<td><input type="text" name="user_name" class="input"/></td>
			<th>닉네임 <em>*</em></th>
			<td><input type="text" name="user_nick" class="input"/></td>
		</tr>
		<tr>
			<th>일반전화</th>
			<td>
				<input type="text" name="user_phone[]" class="input" size="3"/> -
				<input type="text" name="user_phone[]" class="input" size="4"/> -
				<input type="text" name="user_phone[]" class="input" size="4"/>
			</td>
			<th>핸드폰</th>
			<td>
				<input type="text" name="user_mobile[]" class="input" size="3"/> -
				<input type="text" name="user_mobile[]" class="input" size="4"/> -
				<input type="text" name="user_mobile[]" class="input" size="4"/>
			</td>
		</tr>
		<tr>
			<th>생년월일</th>
			<td>
				<input type="text" name="user_birth_date[]" class="input" size="3"/>년
				<input type="text" name="user_birth_date[]" class="input" size="2"/>월
				<input type="text" name="user_birth_date[]" class="input" size="2"/>일
			</td>
			<th>성별</th>
			<td>
				<input type="radio" name="user_sex" value="M" id="r1m" checked="checked"/> <label for="r1m">남성</label>
				<input type="radio" name="user_sex" value="F" id="r1f"/> <label for="r1f">여성</label>
			</td>
		</tr>
		<tr>
			<th>자기소개</th>
			<td colspan="3">
				<textarea name="user_memo" rows="4"></textarea>			
			</td>
		</tr>
		<tr>
			<th>정보공개</th>
			<td colspan="3">
				<input type="radio" name="user_info_public" value="T" id="r2m"/> <label for="r2m">공개</label>
				<input type="radio" name="user_info_public" value="F" id="r2f" checked="checked"/> <label for="r2f">비공개</label>			
			</td>
		</tr>
	</tbody>
	<tfoot>
		<tr>
			<td colspan="10">
				<div class="fl">
					<a id="btn_join" class="btn" href="javascript:;">가입</a>
				</div>
			</td>
		</tr>
	</tfoot>
</table>
</form>
<!--{**************************************************************************}-->
<script>
(function($){
	$('#btn_join').click(function(){
		if($('form[name=join_form] :text[name=user_login_id]').val() == '')
		{
			alert('아이디는 필수 입력사항입니다.');
			return $('form[name=join_form] :text[name=user_login_id]').focus();
		}
		if($('form[name=join_form] :text[name=user_login_id]').val().length < 5 || $('form[name=join_form] :text[name=user_login_id]').val().length > 12)
		{
			alert('아이디는 5자 이상 12자 이내의 영문소문자+숫자만 가능합니다.');
			return $('form[name=join_form] :text[name=user_login_id]').focus();
		}
		if($("form[name=join_form] :hidden[name=login_id_validation]").val() != $('form[name=join_form] :text[name=user_login_id]').val())
		{
			alert('아이디 중복체크를 확인하십시오.');
			return $('form[name=join_form] :text[name=user_login_id]').focus();
		}
		if($('form[name=join_form] :text[name=user_email]').val() == '')
		{
			alert('Email은 필수 입력사항입니다.');
			return $('form[name=join_form] :text[name=user_email]').focus();
		}
		if($("form[name=join_form] :hidden[name=email_validation]").val() != $('form[name=join_form] :text[name=user_email]').val())
		{
			alert('Email 중복체크를 확인하십시오.');
			return $('form[name=join_form] :text[name=user_email]').focus();
		}
		if($('form[name=join_form] :password[name=user_login_passwd]').val() == '')
		{
			alert('비밀번호는 필수 입력사항입니다 .');
			return $('form[name=join_form] :password[name=user_login_passwd]').focus();
		}
		if($('form[name=join_form] :password[name=user_login_passwd]').val().length < 6)
		{
			alert('비밀번호는 6자 이상이여야 합니다.');
			return $('form[name=join_form] :password[name=user_login_passwd]').focus();
		}
		if($('form[name=join_form] :password[name=user_login_passwd]').val() != $('form[name=join_form] :password[name=confirm_passwd]').val())
		{
			alert('비밀번호와 비밀번호 확인이 일치하지않습니다.');
			$('form[name=join_form] :password[name=confirm_passwd]').val('');
			return $('form[name=join_form] :password[name=confirm_passwd]').focus();
		}
		if($('form[name=join_form] :text[name=user_name]').val() == '')
		{
			alert('이름은 필수 입력사항입니다 .');
			return $('form[name=join_form] :text[name=user_name]').focus();
		}
		if(isOnlyHangul($('form[name=join_form] :text[name=user_name]').val()) == false)
		{
			alert('이름은 한글만 입력하십시오.');
			return $('form[name=join_form] :text[name=user_name]').focus();
		}
		if($('form[name=join_form] :text[name=user_nick]').val() == '')
		{
			alert('닉네임은 필수 입력사항입니다 .');
			return $('form[name=join_form] :text[name=user_nick]').focus();
		}
		if(confirm('기입하신 정보로 회원 가입하시겠습니까?'))
		{
			$('form[name=join_form]').submit();		
		}
	});
	$("form[name=join_form] :text[name=user_login_id]").keypress(function(e){
		if(e.keyCode == 13)	
		{
			$('#btn_id_check').focus();
			$('#btn_id_check').click();
		}
	});
	$("form[name=join_form] :text[name=user_email]").keypress(function(e){
		if(e.keyCode == 13)
		{
			$('#btn_email_check').focus();
			$('#btn_email_check').click();
		}
	});
	$('#btn_id_check').click(function(){
		$("form[name=join_form] :hidden[name=login_id_validation]").val('');
		$('form[name=join_form] :text[name=user_login_id]').removeClass('validated');
		if($('form[name=join_form] :text[name=user_login_id]').val() == '')
		{
			alert('아이디는 필수 입력사항입니다.');
			return $('form[name=join_form] :text[name=user_login_id]').focus();
		}
		if($('form[name=join_form] :text[name=user_login_id]').val().length < 5 || $('form[name=join_form] :text[name=user_login_id]').val().length > 12)
		{
			alert('아이디는 5자 이상 12자 이내의 영문+숫자만 가능합니다.');
			return $('form[name=join_form] :text[name=user_login_id]').focus();
		}
		$.post('/user/check', {'mode':'user_login_id','val':$('form[name=join_form] :text[name=user_login_id]').val()}, function(json){
			if(json.error == true)
			{
				alert(json.msg);
				$('form[name=join_form] :text[name=user_login_id]').val('');
				return $('form[name=join_form] :text[name=user_login_id]').focus();
			}
			$('form[name=join_form] :text[name=user_login_id]').addClass('validated');
			$("form[name=join_form] :hidden[name=login_id_validation]").val(json.val);
		},'json');
	});
	$('#btn_email_check').click(function(){
		$("form[name=join_form] :hidden[name=email_validation]").val('');
		$('form[name=join_form] :text[name=user_email]').removeClass('validated');
		$.post('/user/check', {'mode':'user_email','val':$('form[name=join_form] :text[name=user_email]').val()}, function(json){
			if(json.error == true)
			{
				alert(json.msg);
				$('form[name=join_form] :text[name=user_email]').val('');
				return $('form[name=join_form] :text[name=user_email]').focus();
			}
			$('form[name=join_form] :text[name=user_email]').addClass('validated');
			$("form[name=join_form] :hidden[name=email_validation]").val(json.val);
		},'json');
	});
})(jQuery);
function isEmail(el)
{
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	return (el.search(filter) == -1 ? false : true);
}
function isOnlyHangul(el)
{
	for (i = 0; i < el.length; i++)
	{
	    if (!((el.charCodeAt(i) > 0x3130 && el.charCodeAt(i) < 0x318F) ||(el.charCodeAt(i) >= 0xAC00 && el.charCodeAt(i) <= 0xD7A3)))  
	    {
	        return false;
	    }
	}
	return true;
}
function isInt(el)
{
	if (isNaN(parseInt(el)) || (parseInt(el) != parseFloat(el)))
	{
		return false;
	}
	return true;
}
</script>
<!--{**************************************************************************}-->